<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, height=device-height initial-scale=1, maximum-scale=1, user-scalable=no">
	<title>专车接送购物</title>
	<style>
		body{padding: 0px; margin: 0px;}
		.d{
			padding: 15px;
		}
		.d input{width: 100%; height: 40px; line-height: 40px; border: 1px solid #dedede; border-radius: 3px; margin-bottom: 10px; padding-left: 10px; box-sizing: border-box; outline: none}
		.d a{display: block; width: 100%; height: 40px; line-height: 40px; border-radius: 3px; background-color: #f60; color: #fff; font-size: 14px; text-align: center; text-decoration: none}
	</style>
</head>
<body>
	<div>
		<img src="/images/car.png" style="width: 100%" alt="">
	</div>
	<div class="d">
		<form action="">
		<input type="hidden" name="token" value="<?php echo $token?>">
		<input type="text" name="name" placeholder="请填写您的姓名">
		<input type="text" name="phone" placeholder="请填写您的手机号码">
		<input type="text" name="date" placeholder="请填写接送的日期">
		<input type="text" name="address" placeholder="请填写您的地址">
		</form>
		<a href="javascript:;">确定提交</a>
	</div>
</body>
</html>
<script type="text/javascript" src="/assets/jquery.min.js"></script>
<script type="text/javascript">

	$('.d a').on('click',function(){
		var timestamp = Date.parse(new Date());
		timestamp = Math.round(timestamp / 1000);
		
		if(localStorage.getItem('car-time')){
			var t = parseInt(localStorage.getItem('car-time'));
			if(timestamp - t < 3600*24){
				alert('你今天已经提交过请求了！');
				return;
			}
		}

		if(!$('input[name=name]').val()){
			alert('请填写你的姓名');
			return;
		}
		if(!$('input[name=phone]').val()){
			alert('请填写您的手机号码');
			return;
		}
		if(!$('input[name=date]').val()){
			alert('请填写接送的日期');
			return;
		}
		if(!$('input[name=address]').val()){
			alert('请填写您的地址');
			return;
		}

		$.post('/mobile/index/car_save', $('form').serialize(), function(data, textStatus, xhr) {
			var json = $.parseJSON(data);
			if(json.code == 1){
				alert(json.msg);
			}else{
				var timestamp = Date.parse(new Date());
				timestamp = Math.round(timestamp / 1000);
				localStorage.setItem('car-time',timestamp);
				localStorage.setItem('car-id',json.id);
				alert('提交成功');
			}
		});

	})
</script>